import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * @author caiwl
 * @date 2020/11/11 13:46
 */
public class CSVDemo {
    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        Workbook wb = new XSSFWorkbook();
        Sheet sheet = wb.createSheet("Sheet1");
        Row row; Cell cell;
        for (int i = 0; i < 1000000; i++) {
            row = sheet.createRow(i);
            cell = row.createCell(0);
            cell.setCellValue(i + 1);
        }

        try (OutputStream fileOut = new FileOutputStream("workbook.xlsx")) {
            wb.write(fileOut);
        } catch (Exception e) {

        } finally {
            wb.close();
            System.out.println("Done in " + (System.currentTimeMillis() - start) / 1000 + " s.");
        }
    }
}
